from django.db import models

# Create your models here.
# class Author(models.Model):
#     ...

class Book(models.Model):
    title = models.CharField(max_length=30,
                             null=False,
                             unique=True,
                             verbose_name='书名')  # varchar(30)
    pub = models.CharField(max_length=50,
                           verbose_name='出版社',
                           null=True
                           )
    price = models.DecimalField(decimal_places=2,
                                max_digits=7,
                                default=88888,
                                verbose_name='定价')   # Decimal(7, 2)
    market_price = models.DecimalField(
        max_digits=7,
        decimal_places=2,
        verbose_name='零售价',
        default='99999'
    )
    def __str__(self):
        return "书名：" + self.title

    class Meta:
        # db_table = 'mybook'
        # verbose_name = 'boooooooook'
        # verbose_name_plural = 'bookkkkkkkkkkkkkkkkkk'
        pass

class Author(models.Model):
    name = models.CharField(max_length=30)
    age = models.IntegerField(verbose_name='年龄',
                              default=1)
    email = models.EmailField(verbose_name='邮箱',
                              default='xxx@yyy.zzz')
    def __str__(self):
        return "作者：" + self.name

class Wife(models.Model):
    name = models.CharField(max_length=30,
                            verbose_name='姓名')
    author = models.OneToOneField(Author)








